/*
**  gui.h
**  Copyright 2011, Zane Sims
**
**  This file is part of brick-breaker-game.
**
**  brick-breaker-game is free software: you can redistribute it
**  and/or modify it under the terms of the GNU General Public
**  License as published by the Free Software Foundation, either
**  version 3 of the License, or (at your option) any later version.
**
**  brick-breaker-game is distributed in the hope that it will be useful,
**  but WITHOUT ANY WARRANTY; without even the implied warranty of
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**  GNU General Public License for more details.
**
**  You should have received a copy of the GNU General Public License
**  along with brick-breaker-game.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef GUI_H

#include <allegro5/allegro.h>
#include <allegro5/allegro_image.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_font.h>

/* A clickable is the basic building block for creating simple widgets.
 * Essentially, it is a rectangle with visual properties that can be added
 * to a ClickableSet. A clickable set can be traversed to process mouse click
 * events that pertain to the clickables within it. */
typedef struct _Clickable
{
	void *parent_set; /* The ClickableSet parent for this clickable */
	ALLEGRO_BITMAP *icon;
	ALLEGRO_BITMAP *img;
	ALLEGRO_COLOR back_color; /* The background color to use if img is NULL */
	int transparent;
	ALLEGRO_FONT *font;
	ALLEGRO_COLOR text_color;
	char text[256];
	int text_align;
	ALLEGRO_COLOR border_color;
	int border_size;
	int x1;
	int y1;
	int x2;
	int y2;
	int hovering;
	int (*click)(int mouse_x, int mouse_y, struct _Clickable *c);
	int (*hover)(int mouse_x, int mouse_y, struct _Clickable *c, int on);
}Clickable;

typedef struct _ClickableSet
{
	int slots;
	Clickable **clickables;
}ClickableSet;


ClickableSet* new_clickable_set();
void free_clickable_set(ClickableSet *cs);
void process_clickable_set_clicks(ClickableSet *cs, int mouse_x, int mouse_y);
void process_clickable_set_hovers(ClickableSet *cs, int mouse_x, int mouse_y);

int reg_clickable(Clickable *c);
void unreg_clickable(Clickable *c);
void draw_clickable(Clickable *c);

void draw_outside_border(int x1, int y1, int x2, int y2, ALLEGRO_COLOR color, int size);

#endif


